package com.example.mobile0123456789hwh0421;

import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private TextView tvMainTitle;
    private RecyclerView rvMainStudent;
    private List<Student> list = new ArrayList();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        initData();
//      线性布局
        rvMainStudent.setLayoutManager(new LinearLayoutManager(this));
//      设置适配器
        rvMainStudent.setAdapter(new StudentRVAdapter(list));
    }
    private void initView() {
        tvMainTitle = (TextView) findViewById(R.id.tv_main_title);
        rvMainStudent = (RecyclerView) findViewById(R.id.rv_main_student);
    }
    private void initData(){
        list.add(new Student("小明",18,"移动1班","13500001111"));
        list.add(new Student("小红",19,"移动2班","13500001111"));
        list.add(new Student("小丽",20,"移动3班","13500001111"));
        list.add(new Student("小青",21,"移动1班","13500001111"));
        list.add(new Student("小张",22,"移动2班","13500001111"));
        list.add(new Student("小李",19,"移动3班","13500001111"));
    }
}